package com.CST.controller.zx;

import com.CST.bo.zx.ProjectAppealBO;
import com.CST.bo.zx.ProjectAppealDetailBO;
import com.CST.bo.zx.ProjectAppealHandleBO;
import com.CST.common.api.ResultObject;
import com.CST.entity.zx.ZxProjectAppeal;
import com.CST.service.zx.IZxProjectAppealService;
import com.CST.util.PageHelperTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author 伍文毅
 * @Date 2023 03 27 10 18
 **/
@Api(tags = {"项目申诉处理"})
@RestController
@RequestMapping("/zxProjectHandleAppeal")
public class ZxProjectAppealHandleController {
    @Autowired
    private IZxProjectAppealService targetService;
    @PostMapping("/pageForZxProjectAppeal")
    @ApiOperation("分页显示项目申诉处理记录")
    public ResultObject pageForZxProjectAppeal(@RequestBody ProjectAppealBO projectAppealBO) {
        List<ZxProjectAppeal> list = targetService.queryAlleHandleAppeal(projectAppealBO);
        return ResultObject.success(PageHelperTool.excutePageInfo(list,projectAppealBO.getPageNo(), projectAppealBO.getPageSize()));
    }

    @PostMapping("/queryZxProjectAppealForDetail")
    @ApiOperation("查询项目申诉记录基本信息")
    public ResultObject queryZxProjectAppealForDetail(@RequestBody ProjectAppealDetailBO projectAppealDetailBO) {
        Map<String, Object> map = targetService.queryZxProjectAppealForDetail(projectAppealDetailBO);
        return ResultObject.success(map);
    }

    @PutMapping("/alreadyEditForZxProjectAppeal")
    @ApiOperation("申诉处理，修正和驳回，参数handlingOpinions 处理意见")
    public ResultObject alreadyEditForZxProjectAppeal(@RequestBody ProjectAppealHandleBO projectAppealHandleBO) {
        Boolean flag = targetService.alreadyEditForZxProjectAppeal(projectAppealHandleBO);
        return flag?ResultObject.success("修改成功"):ResultObject.failed("修改失败");
    }

    @GetMapping("/getNoHandleNum")
    @ApiOperation("查询未处理的数量,0表示没有")
    public ResultObject getNoHandleNum() {
        int noHandleNum = targetService.getNoHandleNum();
        return ResultObject.success(noHandleNum);
    }
}
